
<style>
    .form-horizontal .form-group{margin-right: -50px;}
    .col-sm-9{padding-right: 0;}
	.tm .btn { margin-bottom:5px;}
</style>
<div class="page-content">
    <div class="row">
        <div class="col-sm-9">
           
            <form action="" method="post" class="form-horizontal form-validate" enctype="multipart/form-data">
            <input type="hidden" name="template" value="" />
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 left-label" >模板名称</label>
                <div class="col-sm-9 col-xs-12"> 
                    <input type="text" name="name" ng-model="pagedata.item.title" class="form-control" value="" placeholder="模版名称" data-rule-required='true' />
                    
                </div>
            </div>
			<div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 left-label" >打印列格式</label>
                <div class="col-sm-9 col-xs-12">
                    <span class="help-block">例如: 名称:16|单价:6|数量:5|金额:5 解释: 名字 占据16位,单价占据6位,数量占据5位,金额占据5位;总共每行是32个字符,每个中文或中文标点占用2字符;请严格按照格式来!</span>
                    <input type="text" name="name" ng-model="pagedata.item.print_style" class="form-control" value="" placeholder="" data-rule-required='true' />
                    
                </div>
            </div>
			<div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 left-label" >打印头部</label>
                <div class="col-sm-9 col-xs-12">
                   
                    <input type="text" name="name" ng-model="pagedata.item.print_top" class="form-control" value="" placeholder="" data-rule-required='true' />
                    
                </div>
            </div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 left-label">打印条形码</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<label class="right-label">
						<div ng-show="pagedata.item.iscode==1" class="switch switchOn" ng-click="pagedata.item.iscode=0"></div>
						<div ng-show="pagedata.item.iscode!=1" class="switch" ng-click="pagedata.item.iscode=1"></div>
					</label>
				</div>
			</div>
             <div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 left-label">打印二维码</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<label class="right-label">
						<div ng-show="pagedata.item.isqrcode==1" class="switch switchOn" ng-click="pagedata.item.isqrcode=0"></div>
						<div ng-show="pagedata.item.isqrcode!=1" class="switch" ng-click="pagedata.item.isqrcode=1"></div>
					</label>
				</div>
			</div>
			<div ng-show="pagedata.item.isqrcode==1" class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 left-label">二维码地址</label>
                <div class="col-sm-9 col-xs-12">                 
                    <input type="text" name="name" ng-model="pagedata.item.qrcode" class="form-control" value="" placeholder="" data-rule-required='true' />                   
                </div>
            </div>
			 <div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 left-label">打印商品编码</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<label class="right-label">
						<div ng-show="pagedata.item.goodssn==1" class="switch switchOn" ng-click="pagedata.item.goodssn=0"></div>
						<div ng-show="pagedata.item.goodssn!=1" class="switch" ng-click="pagedata.item.goodssn=1"></div>
					</label>
				</div>
			</div>
			 <div ng-repeat="item in pagedata.item.print_data" class="form-group key_item">
                    <label class="col-xs-12 col-sm-3 col-md-2 left-label">打印内容</label>
                     <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" id="value{{$index}}"  ng-model="item.value" class="form-control valid" value="" aria-invalid="false">
                            <div class="input-group-btn"><button class="btn btn-danger" type="button" ng-click="pagedata.item.print_data.splice($index,1)">删除</button></div>
                        </div>
                        <span class="help-block">
                               <label class="radio-inline"><input type="radio" value="0" ng-model="item.textstytle" ng-checked="item.textstytle==0"> 默认</label>
                               <label class="radio-inline"><input type="radio" value="1" ng-model="item.textstytle" ng-checked="item.textstytle==1"> 加粗 </label>
                               <label class="radio-inline"><input type="radio" value="2" ng-model="item.textstytle" ng-checked="item.textstytle==2"> 居中</label>
                        </span>
                        <span class="help-block">例如: <span class="">[商品名称]|[商品价格]|[商品数量]|[单商品合计]</span> ----  输入要打印的内容,如果打印一整句,请不要加 | 超出长度会折行,</span>
                    </div>
             </div>
            <div class="form-group sms-template-1" >
                <label class="col-xs-12 col-sm-3 col-md-2 left-label"></label>
                <div class="col-sm-9 col-xs-12">
                    <a class="btn btn-default btn-add-type" href="javascript:;" ng-click="pagedata.item.print_data.push({'value':'','textstytle':'0'});"><i class="fa fa-plus" title=""></i> 增加一条数据值</a>
                </div>
            </div>
			 <div class="modal-sub"><button class="btn btn-primary" href="javascript:" ng-click="post(pagedata.item,'post')">提交</button></div>
           </form>

        </div>
        <div class="col-sm-3">
            <div class="panel panel-default" style="width:200px;margin-left:20px;">
                <div class="panel-heading">
                    <select class="form-control" onclick="$('.tm').hide();$('.tm-' + $(this).val()).show()">
                        <option value="">选择模板变量类型</option>
                        <option value="order">订单类</option>
                        <option value="upgrade">升级类</option>
                        <option value="rw">充值提现类</option>
                       
                        <option value="commission">分销类</option>
                      
                        <option value="globonus">股东类</option>
                       
                        <option value="merch">多商户类</option>
                    
                        <option value="login">登录/注册类</option>
                    </select>
                </div>
                <div class="panel-body tm tm-upgrade" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm ">商城名称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">粉丝昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新等级</a>
                </div>
                <div class="panel-heading tm tm-rw" style="display:none">充值</div>

                <div class="panel-body tm tm-rw" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">支付方式</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">赠送金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">实际到账</a>
                </div>

                <div class="panel-heading tm tm-rw" style="display:none">充值退款</div>
                <div class="panel-body tm tm-rw" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">支付方式</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">赠送金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">实际到账</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">退款金额</a>
                </div>

                <div class="panel-heading tm tm-rw" style="display:none">提现</div>
                <div class="panel-body tm tm-rw" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">提现金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">提现时间</a>
                </div>
                <div class="panel-heading tm tm-order" style="display:none">
                    订单信息
                </div>
                <div class="panel-body tm tm-order" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">商城名称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">粉丝昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">运费</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">商品详情</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">单品详情</a>(单品商家下单通知变量)
                    <a href='JavaScript:' class="btn btn-default btn-sm">快递公司</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">快递单号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">购买者姓名</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">购买者电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">收货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">下单时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">支付时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">发货时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">收货时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店营业时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">虚拟物品自动发货内容</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">虚拟卡密自动发货内容</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">自提码</a>

                </div>
                <div class="panel-heading tm tm-order" style="display:none">
                    售后相关
                </div>
                <div class="panel-body tm tm-order" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">售后类型</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">退款金额</a>

                    <a href='JavaScript:' class="btn btn-default btn-sm">退货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">换货快递公司</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">换货快递单号</a>

                </div>

                <div class="panel-heading tm tm-order" style="display:none">
                    订单状态更新
                </div>
                <div class="panel-body tm tm-order" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm"></a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">粉丝昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单编号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">原收货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新收货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单原价格</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单新价格</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">修改时间</a>

                </div>
                <div class="panel-heading tm tm-commission" style="display:none">成为下级或分销商</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">新增下线通知</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">下线层级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">下级昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">下级付款类</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">下级昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单编号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">商品详情</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">佣金金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">下线层级</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">提现申请和佣金打款类</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">提现方式</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">分销商等级升级通知</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧一级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧二级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧三级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新一级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新二级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新三级分销比例</a>
                </div>



                <div class="panel-heading tm tm-globonus" style="display:none">成为股东</div>
                <div class="panel-body tm tm-globonus" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                </div>

                <div class="panel-heading tm tm-globonus" style="display:none">股东等级升级通知</div>
                <div class="panel-body tm tm-globonus" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧分红例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新分红比例</a>
                </div>
                <div class="panel-heading tm tm-globonus" style="display:none">分红发放通知</div>
                <div class="panel-body tm tm-globonus" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">打款方式</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">金额</a>
                </div>

                <div class="panel-heading tm tm-merch" style="display:none">入驻申请</div>
                <div class="panel-body tm tm-merch" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">商户名称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">主营项目</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">手机号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请时间</a>
                </div>
                <div class="panel-heading tm tm-merch" style="display:none">入驻申请(用户)</div>
                <div class="panel-body tm tm-merch" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">驳回原因</a>
                </div>

                <div class="panel-heading tm tm-login" style="display:none">登录/注册</div>
                <div class="panel-body tm tm-login" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">验证码</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">商城名称</a>
                </div>

                <div class="panel-footer">
                    点击变量后会自动插入选择的文本框的焦点位置，在发送给粉丝时系统会自动替换对应变量值
                    <div class="text text-danger">
                        注意：以上模板消息变量只适用于系统类通知，会员群发工具不适用
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

 
<script language='javascript'>
scope.pagedata.uptmp=function(){
					var print_data=scope.pagedata.item.print_data
					var tmp=scope.pagedata.item.first+'\n'
					for (i = 0; i < print_data.length; i++) {
						var num = i+1
						tmp +=print_data[i].title+'：'+print_data[i].value+'\n'
					}
					tmp +=scope.pagedata.item.footer
					scope.pagedata.item.tmp=tmp
					scope.$evalAsync();
}
scope.pagedata.uptmp();
    $(function () {
        require(['jquery.caret'],function(){
            var jiaodian;
            $(document).on('focus', 'input,textarea',function () {
                jiaodian = this;
            });

            $("a[href='JavaScript:']").click(function () {
                if (jiaodian) {
                    $(jiaodian).insertAtCaret("["+this.innerText+"]" );
					var print_data=scope.pagedata.item.print_data
					for (i = 0; i < print_data.length; i++) {
						scope.pagedata.item.print_data[i].value=$("#value"+i).val();
					}
					scope.$evalAsync();
                }
            })

        });
    })
 
</script>

